
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class AddContactValidationForm extends ActionForm{

	
		public String Nom;
		
		public String Prenom;
		
		public String Email;
		
		public String Adresse;
		
	
	//get and set methods
	
		public String getNom(){
		return Nom;}
		
		public void setNom(String newNom){
		this.Nom= newNom;}
		
		public String getPrenom(){
		return Prenom;}
		
		public void setPrenom(String newPrenom){
		this.Prenom= newPrenom;}
		
		public String getEmail(){
		return Email;}
		
		public void setEmail(String newEmail){
		this.Email= newEmail;}
		
		public String getAdresse(){
		return Adresse;}
		
		public void setAdresse(String newAdresse){
		this.Adresse= newAdresse;}
		
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletRespons response){
		String success = new String("success");
		String error = new String("error");
		String Nom = (String) request.getAttribute("Nom");
		String Prenom = (String) request.getAttribute("Prenom");
		String Email = (String) request.getAttribute("Email");
		String Adresse = (String) request.getAttribute("Adresse");
		return mapping.findForward(success);
	}
		
	public ActionForward validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrores errors = new ActionReerors();if(getNom() == null || getNom().length() < 1){
			errors.add("Nom", new ActionMassage("creation.fn.error.required"));
		}
		if(getPrenom() == null || getPrenom().length() < 1){
			errors.add("Prenom", new ActionMassage("creation.fn.error.required"));
		}
		if(getEmail() == null || getEmail().length() < 1){
			errors.add("Email", new ActionMassage("creation.fn.error.required"));
		}
		if(getAdresse() == null || getAdresse().length() < 1){
			errors.add("Adresse", new ActionMassage("creation.fn.error.required"));
		}
		
		return errors;
	}
	
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.Nom = null;
		this.Prenom = null;
		this.Email = null;
		this.Adresse = null;
	}
	
}
	
	
	